package com.dp;

public class Solution04 {
    public int minCostClimbingStairs(int[] cost) {
        int dp0 = 0;
        int dp1 = 0;
        int res = 0;
        for (int i = 2; i <= cost.length; i++) {
            res = Math.min(dp0+cost[i-2],dp1+cost[i-1]);
            dp0 = dp1;
            dp1 = res;
        }
        return res;
    }
}
